//======================================================
// Decode and interpolate PCA-compressed SH
// =======================================================

using UnityEngine;

public class RuntimeProbeDecoder : MonoBehaviour
{
    public TextAsset compressedJson;
    public CompressedProbeData data;
    public KDTree tree;

    void Awake()
    {
        data = JsonUtility.FromJson<CompressedProbeData>(compressedJson.text);
        tree = new KDTree(data.positions);
    }

    //public Color SampleSH(Vector3 worldPos)
    //{
       // int idx = tree.FindNearest(worldPos);
        //float[] coeff = data.coefficients[idx];
        //float[] col = new float[3];
        //for (int c = 0; c < 3; c++)
        //for (int k = 0; k < data.pcaAxes.GetLength(0); k++)
       // {
        //    col[c] += coeff[k] * data.pcaAxes[k, c * 9]; // simplified indexing
       // }

        //return new Color(col[0] + data.mean[0], col[1] + data.mean[1], col[2] + data.mean[2]);
    //}
}